package com.attain.mapper;

import com.attain.pojo.News;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface NewsMapper {
    @Insert("INSERT INTO news (title, content, source, create_time, create_user_id) VALUES (#{title}, #{content}, #{source}, #{createTime}, #{createUserId})")
    void add(News news);

    @Select("SELECT * FROM news")
    List<News> findAll();

    @Select("SELECT * FROM news WHERE id = #{id}")
    News findById(Integer id);

    @Update("UPDATE news SET title = #{title}, content = #{content}, source = #{source} WHERE id = #{id}")
    void update(News news);

    @Delete("DELETE FROM news WHERE id = #{id}")
    void delete(Integer id);
}